package com.nus.dataaccess.dao.event;

import com.nus.dataaccess.dao.base.BaseEntity;
import com.nus.dataaccess.dao.user.UserAccount;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author T W Ong
 */

@Entity
@Table(name="EVENT_REGISTRATION")
public class EventRegistration extends BaseEntity{
    
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    public Long getId() {return id;}
    public void setId(Long id) {this.id = id;}
    @Override
    public Serializable getPk() {return this.getId();}
        
 
    @Column(name="EVENT_ID")
    private Long eventId;
    public Long getEventId() {return eventId;}
    public void setEventId(Long eventId) {this.eventId = eventId;}


    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="EVENT_ID", referencedColumnName="ID",insertable=false,updatable=false)
    private Event event;
    public Event getEvent() {return event;}
    public void setEvent(Event event) {
        this.event = event;
    }

    @Column(name="USER_ACCOUNT_ID")
    private Long userAccountId;
    public Long getUserAccountId() {return userAccountId;}
    public void setUserAccountId(Long userAccountId) {this.userAccountId = userAccountId;}
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="USER_ACCOUNT_ID", referencedColumnName="ID",insertable=false,updatable=false)
    private UserAccount userAccount;
    public UserAccount getUserAccount() {return userAccount;}
    public void setUserAccount(UserAccount userAccount) {
        this.userAccount = userAccount;
        this.setUserAccountId( (userAccount == null) ? null : userAccount.getId() );
    }

}

